/**
 * The plugin interface for logger registration.
 */
jsx3.lang.Class.defineInterface(
        "ux.core.plugin.LoggerInterface",
        null,
        function(plugin) {


            /**
             * Pre-implemented function that should NOT be overridden by the plugin component.
             * The plugin component should call this function on themselves to register its logger.
             * @param namespace {String} the namespace of the plugin package that the resource belongs to.
             * @param strPath {String} The path to the xml document for logger configuration, relative to the context root of its owning component.
             */
            plugin.prototype.registerLogger = function(namespace, strSrc) {
                ux.core.util.Log.SYSTEM.trace("Registering logger for " + namespace)
                try {
                    var handler = jsx3.util.Logger.Manager.getManager().getHandler("ux_admin_appMonitor")
                    var xmlDoc = ux.core.System.loadResource(strSrc, namespace, null, "xml", false);
                    var list = xmlDoc.selectNodes("//configuration/logger[starts-with(@name, '" + namespace + "')]") ;
                    var iterator = list.iterator();
                    var next = null;
                    var logger = null;
                    var name, level, useParent
                    while (iterator.hasNext()) {
                        next = iterator.next()
                        name = next.getAttribute("name")
                        level = next.getAttribute("level")
                        useParent = next.getAttribute("useParent")
                        useParent = (useParent == 'true' )? true : false
                        ux.core.util.Log.SYSTEM.trace("name = " + name + " level = " + level + " useParent = " + useParent)
                        logger = jsx3.util.Logger.getLogger(name);
                        logger.setUseParentHandlers(useParent);
                        logger.setLevel(this.getIntLevel(level));
                        logger.addHandler(handler);
                    }
                }
                catch(e) {
                    ux.core.util.Log.SYSTEM.error(e)
                    return
                }

            }

            /** returns the in value of the logger level
             * @param level {String} like ERROR, TRACE, etc...
             * @private
             * @jsxobf-clobber
             */
            plugin.prototype.getIntLevel = function(level) {
                var intLevel = jsx3.util.Logger.ERROR
                switch (level) {
                    case "DEBUG":
                        intLevel = jsx3.util.Logger.DEBUG;
                        break;
                    case "ERROR":
                        intLevel = jsx3.util.Logger.ERROR;
                        break;
                    case "FATAL":
                        intLevel = jsx3.util.Logger.FATAL;
                        break;
                    case "GLOBAL":
                        intLevel = jsx3.util.Logger.GLOBAL;
                        break;
                    case "INFO":
                        intLevel = jsx3.util.Logger.INFO;
                        break;
                    case "OFF":
                        intLevel = jsx3.util.Logger.OFF;
                        break;
                    case "TRACE":
                        intLevel = jsx3.util.Logger.TRACE;
                        break;
                    case "WARN":
                        intLevel = jsx3.util.Logger.WARN;
                        break;

                }
                return intLevel;
            }


        }
        );